package com.zige.zige.utils;

import android.app.ProgressDialog;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.PopupWindow;

public class DialogUtil {

	private static ProgressDialog pd;

	public static ProgressDialog showProgress(Context c, String msg) {
		try{
//			pd = ((NaviBase)c).pd;
		}catch(ClassCastException e){
			LogUtils.e(e);
		}
		try {
			if (pd == null)
				pd = new ProgressDialog(c);
			pd.setMessage(msg);
			pd.setIndeterminate(true);
			// pd.setCancelable(false);
			pd.setCanceledOnTouchOutside(false);
			pd.setProgressStyle(ProgressDialog.STYLE_SPINNER);
			pd.show();
		} catch (Exception e) {

		}
		return pd;
	}

	public static ProgressDialog showProgress(Context c) {
		try {
			if (c == null)
				return null;
			if (pd == null) {
				pd = new ProgressDialog(c);
			}
//			pd.setMessage(c.getString(R.string.dialog_defult_msg));
			pd.setIndeterminate(true);
			// pd.setCancelable(false);
			pd.setCanceledOnTouchOutside(false);
			pd.setProgressStyle(ProgressDialog.STYLE_SPINNER);
			pd.show();
		} catch (Exception e) {
			LogUtils.e(e);
		} finally {
			return pd;
		}
	}

	public static void dismissProgress(ProgressDialog dialog) {
		try {
			if (dialog != null && dialog.isShowing())
				dialog.dismiss();
//			pd = null;
		} catch (Exception e) {
			LogUtils.e(e);
		}
	}

	class PassWordDialog{
		private Context context;
		private LayoutInflater inflater;
		private View parent;
		PopupWindow pDialog;
		public PassWordDialog(Context ctx, View p) {
			context = ctx;
			parent = p;
			inflater = LayoutInflater.from(ctx);
		}
		private void createDialog(){
			pDialog = new PopupWindow(context);
			
		}
	}
	
}
